<?php
	header("Content-type: text/html;charset=utf8");
	require_once("../db/dbclass.php");
	require_once("../model/userinfo.php");
	require_once("../utils/common.php");
	$myDb=&DbController::getInstance();
	$tweets_id=$_POST['tweet_id'];
	$user_id=$_POST['user_id'];
	$comment_content=$_POST['comment_content'];
	$param="INSERT INTO yj_tweets_comment(tweets_id,user_id,comment_content,comment_time) VALUES('".$tweets_id."','".$user_id."','".$comment_content."','".date('y-m-d h:i:s',time())."')";
	$result=$myDb->exec_query($param);
	if($result==TRUE){
		$param="UPDATE yj_tweets SET comment_num=comment_num+'1' WHERE tweets_id='".$tweets_id."'";
		$result=$myDb->exec_query($param);
		if($result==TRUE){
			$result='{"result":"success"}';
		}
		else{
			$result='{"result":"failure"}';
		}
	}
	else{
		$result='{"result":"success"}';
	}
	echo $result;
?>